using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TablePetDao:DaoBase<TablePet>
    {
        public override void AddPrimaryIndex(TablePet model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TablePet.txt";
        }

        protected override TablePet ParseRowData(string[] rowData)
        {
            TablePet data = new TablePet();
			data.id = rowData [0];
			data.name = rowData [1];
			data.desc = rowData [2];
			data.resName = rowData [3];

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.Scale = 0;
            }
            else
            {
                data.Scale = double.Parse(rowData[4]);
            }
			data.iconName = rowData [5];

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.quality = 0;
            }
            else
            {
                data.quality = int.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.nature = 0;
            }
            else
            {
                data.nature = int.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.expBase = 0;
            }
            else
            {
                data.expBase = int.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.petClass = 0;
            }
            else
            {
                data.petClass = int.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.selloutPrice = 0;
            }
            else
            {
                data.selloutPrice = int.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.hpBase = 0;
            }
            else
            {
                data.hpBase = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.attBase = 0;
            }
            else
            {
                data.attBase = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.pdefBase = 0;
            }
            else
            {
                data.pdefBase = double.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.mdefBase = 0;
            }
            else
            {
                data.mdefBase = double.Parse(rowData[14]);
            }
			data.defaultTalent = rowData [15];

            return data;
        }



    }

}
